﻿using DailyPoetryM.Models;
using System.Globalization;

namespace DailyPoetryM.Converters;

public class PoetryToStringConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        //诗词对象转成一个字符串
        //return value is not Poetry poetry ? null : $"{poetry.Dynasty} {poetry.Author}   {poetry.Snippet}";
        return value is Poetry poetry ? $"{poetry.Dynasty} · {poetry.Author}   {poetry.Snippet}" : (object)null;

    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
